<template>
	<view class="content">
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
			:up="upOption">
			<view class="item" v-for="(item,i) in list" :key="i">
				<view class="item-content">
					<view class="item-content-line">
						<view class="item-content-line-item">
							<view class="item-content-line-item-title" style="margin-bottom: 0;">创建时间:{{item.create_time}}</view>
						</view>
					</view>
					<u-line color="#c5c5c5"></u-line>
					<view class="item-content-line">
						<view class="item-content-line-item">
							<view class="item-content-line-item-title">消费卡</view>
							<view class="item-content-line-item-value">{{item.detail[0].name}}({{item.detail[0].card_number.substring(item.detail[0].card_number.length-4)}})</view>
						</view>
						<view class="item-content-line-item">
							<view class="item-content-line-item-title">消费金额</view>
							<view class="item-content-line-item-value">{{item.detail[0].amount}}</view>
						</view>
						<view class="item-content-line-item">
							<view class="item-content-line-item-title">消费手续费</view>
							<view class="item-content-line-item-value">{{item.detail[0].charge}}</view>
						</view>
						<view class="item-content-line-item">
							<view class="item-content-line-item-title">消费状态</view>
							<view class="item-content-line-item-value">
								<view v-if="item.detail[0].status == 0" style="color: #c0c4cc;" >
									未执行
								</view>
								<view v-else-if="item.detail[0].status == 1" style="color: #5ac752;" >
									执行中
								</view>
								<view v-else-if="item.detail[0].status == 2" style="color: #3c9cff;" >
									已完成
								</view>
								<view v-else-if="item.detail[0].status == 3" style="color: #f56c6c;" >
									已失败
								</view>
							</view>
						</view>
					</view>
					<u-line color="#c5c5c5"></u-line>
					<view class="item-content-line">
						<view class="item-content-line-item">
							<view class="item-content-line-item-title">结算卡</view>
							<view class="item-content-line-item-value">{{item.detail[1].name}}({{item.detail[1].card_number.substring(item.detail[1].card_number.length-4)}})</view>
						</view>
						<view class="item-content-line-item">
							<view class="item-content-line-item-title">结算金额</view>
							<view class="item-content-line-item-value">{{item.detail[1].amount}}</view>
						</view>
						<view class="item-content-line-item">
							<view class="item-content-line-item-title">结算笔数费</view>
							<view class="item-content-line-item-value">{{item.detail[1].charge}}</view>
						</view>
						<view class="item-content-line-item">
							<view class="item-content-line-item-title">结算状态</view>
							<view class="item-content-line-item-value">
								<view v-if="item.detail[1].status == 0" style="color: #c0c4cc;" >
									未执行
								</view>
								<view v-else-if="item.detail[1].status == 1" style="color: #5ac752;" >
									执行中
								</view>
								<view v-else-if="item.detail[1].status == 2" style="color: #3c9cff;" >
									已完成
								</view>
								<view v-else-if="item.detail[1].status == 3" style="color: #f56c6c;" >
									已失败
								</view>
							</view>
						</view>
					</view>
					<u-line color="#c5c5c5"></u-line>
					<view class="item-content-line">
						<view class="item-content-line-item">
							<view class="item-content-line-item-title" style="margin-bottom: 0;">通道:{{item.show_name}}</view>
						</view>
					</view>
					<view class="item-content-line" v-if="item.status==2">
						<view class="item-content-line-item">
							<view class="item-content-line-item-title" style="color: #f56c6c;margin-bottom: 0;">失败原因:{{item.status_message}}</view>
						</view>
					</view>
				</view>
				<!-- <view class="t">
					<view class="l">
						<image :src="item.detail[0].logo" class="img" mode="aspectFill"></image>
						<view class="bankInfo">
							<view class="h3">
								{{item.detail[0].name}}
							</view>
							<view class="p">
								{{item.detail[0].card_number.substring(item.detail[0].card_number.length-4)}}
							</view>
						</view>
					</view>
					<view class="c">
						<view class="hr"></view>
						<view class="hr"></view>
					</view>
					<view class="l">
						<image :src="item.detail[1].logo" class="img" mode="aspectFill"></image>
						<view class="bankInfo">
							<view class="h3">
								{{item.detail[1].name}}
							</view>
							<view class="p">
								{{item.detail[1].card_number.substring(item.detail[1].card_number.length-4)}}
							</view>
						</view>
					</view>
				</view>
				<view class="d">
					<view class="l">
						<view class="h3">
							收银
						</view>
						<view class="p">
							{{item.detail[0].amount}}
						</view>
					</view>
					<view v-if="item.status == 0" class="c active" >
						进行中
					</view>
					<view v-else-if="item.status == 1" class="c active" >
						已完成
					</view>
					<view v-else-if="item.status == 2" class="c" >
						已失败
					</view>
					<view class="l">
						<view class="h3">
							到账
						</view>
						<view class="p">
							{{item.detail[1].amount}}
						</view>
					</view>
				</view>
				<view v-if="item.status==2" style="text-align: center; color: #f00;margin-top: 20rpx;">{{item.status_message}}</view> -->
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import {cashierList} from '@/common/creditcardmachine.api.js'
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				list: [],
				downOption:{},
				upOption:{},
				pagination: {
					current: 1,
					page: 1,
					pageSize: 0,
					total: 0,
				},
			}
		},
		onLoad() {
			let that = this;

		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			console.log('下拉加载')
		},
		created() {

		},
		methods: {
			getList() {
				let that = this;
				let params = {}
				params.page = that.pagination.current;
				params.page_size = 20
				cashierList(params).then(res => {
					console.log(res)
					if (!res.list) {
						res.list = []
					}
					if (!res.pagination) {
						res.pagination = {}
						res.pagination.total = 0
					}
					that.mescroll.endByPage(res.list.length, res.pagination.total)
					that.pagination.page = that.pagination.current
					if (that.pagination.current * 1 == 1) {
						that.list = res.list
					} else {
						that.list = [...that.list, ...res.list]
					}

					that.pagination = res.pagination;
					that.pagination.current = that.pagination.current * 1 + 1
					that.pagination.page = that.pagination.current * 1 + 1
				})
			},

			upCallback() {
				this.getList()
			},
			downCallback() {
				this.pagination.page = 1;
				this.pagination.current = 1;
				this.mescroll.resetUpScroll();
			},
			showCalendar() {
				this.showCalendarStatus = true
			},
		}
	}
</script>
<style>
	page {
		background-color: #f5f5f5;
	}
</style>
<style scoped lang="scss">
	.container {
		padding: 0 30rpx;
	}

	.item-content{
		background: #fff;
		margin: 10rpx 20rpx;
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		.item-content-line{
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			padding: 10rpx 0;
			.item-content-line-item{
				display: flex;
				flex-direction: column;
				align-items: center;
				.item-content-line-item-title{
					font-size: 24rpx;
					font-weight: bold;
					margin-bottom: 10rpx;
				}
				.item-content-line-item-value{
					font-size: 22rpx;
				}
			}
		}
	}
</style>
